#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <cmath>
#include <cstring>
#include <string>
#include <iomanip>
#include <climits>
#include <unordered_map>
#include <unordered_set>
#define int long long
#define x first 
#define y second  
using namespace std;
const int N = 2e6 + 10;
void solve()
{
     int n;
     cin >> n;
     if(n == 1) 
     {
        cout << 1 << endl;
        return;
     }
     int cnt = 0;
     while(n)
     {
        n /= 2;
        cnt++;
     }
     cout << (int)(pow(2,cnt) - 1) << endl;
    /*  int p = 1;
     for(int i = 1; i <= 1e3 - 10; i++)
     {
        p = p + pow(2,i);
        //cout << p << endl;
        if(n <= p)
        {
            cout << p << endl;
            return;
        }
     } */
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr),cout.tie(nullptr);
    int t;
    cin >> t;
    while(t -- )  solve();
    return 0;
}